package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	Mysql
	Redis
	SendSms
	Jwt
	QiNiuYun
}
type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type Redis struct {
	Host     string
	Password string
}
type SendSms struct {
	AccessKeyId     string
	AccessKeySecret string
}
type Jwt struct {
	APP_KEY string
}

type QiNiuYun struct {
	AccessKey string
	SecretKey string
}

var AppConfig Config

func Init() {
	viper.SetConfigFile("../appconfig/conf.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
	}
	err = viper.Unmarshal(&AppConfig)
	if err != nil {
		fmt.Println("配置文件解析失败")
	}
	fmt.Println(AppConfig)
}
